﻿using Google.Protobuf.Collections;
using POGOProtos.Data;
using POGOProtos.Inventory.Item;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PokemonGo.UI.Common
{
    public static class PokemonDataExtends
    {
        /// <summary>
        /// 获取完美度
        /// </summary>
        /// <param name="poke"></param>
        /// <returns></returns>
        public static float Perfect(this PokemonData poke)
        {
            if (poke == null)
            {
                return 0;
            }
            return ((float)(poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina) / (3.0f * 15.0f)) * 100.0f;
        }

        public static string ToItemsString(this IList<ItemAward> items)
        {
            StringBuilder builder = new StringBuilder();
            foreach (var item in items)
                builder.Append($" {item.ItemId}:{item.ItemCount}");
            return builder.ToString();
        }
    }
}
